package luzhin;

import java.io.*;

/**
 * Constants for pieces.
 * @author lacungus
 *
 */
public class Piece implements Serializable {
	private static final long serialVersionUID = 3482948L;

    public static int WHITE = 1;
    public static int BLACK = -1;

	public static int NONE = 0; 
	public static int WK = 1;
	public static int WQ = 2; 
	public static int WB = 3; 
	public static int WN = 4; 
	public static int WR = 5; 
	public static int WP = 6;
	public static int BK = 7;
	public static int BQ = 8; 
	public static int BB = 9; 
	public static int BN = 10; 
	public static int BR = 11; 
	public static int BP = 12;
	
	private static char[] chars = {'.', 'K', 'Q', 'B', 'N', 'R', 'P', 'k', 'q', 'b', 'n', 'r', 'p'};
	
	public static int dxQueen[] = {1, 1, 1, -1, -1, -1, 0, 0};
	public static int dyQueen[] = {0, 1, -1, 0, 1, -1, 1, -1};
	public static int dxRook[] = {1, -1, 0, 0};
	public static int dyRook[] = {0, 0, 1, -1};
	public static int dxBishop[] = {1, 1, -1, -1};
	public static int dyBishop[] = {-1, 1, -1, 1};
	public static int dxKnight[] = {1, 1, -1, -1, 2, 2, -2, -2};
	public static int dyKnigth[] = {2, -2, 2, -2, 1, -1, 1, -1};
	public static int dxKing[] = {1, 1, 1, -1, -1, -1, 0, 0};
	public static int dyKing[] = {0, 1, -1, 0, 1, -1, 1, -1};
	public static int dxWhitePawn[] = {1, 1};
	public static int dyWhitePawn[] = {-1, 1};
	public static int dxBlackPawn[] = {-1, -1};
	public static int dyBlackPawn[] = {-1, 1};	
	
	/**
	 * 
	 * @param piece
	 * @return
	 */
	public static char toChar(int piece) {
		return chars[piece];
	}
	
	/**
	 * 
	 * @param piece
	 * @return Color of the piece.
	 */
	public static int getColor(int piece) {
		if (piece == NONE)
			return 0;
        return piece < BK ? 1 : -1;
	}
}
